package com.airticketbooking.mapper;

import com.airticketbooking.po.Payment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author Mr.J
 * @version 1.0.0
 * @date 2024/11/13
 * @desc
 */
@Mapper
public interface PaymentMapper {


	@Insert("INSERT INTO airticketbooking.payment(pay_type_id,order_id, payment_amount, payment_date_time,update_date_time)" +
			"values" +
			" (#{payTypeId},#{orderId},#{paymentAmount},#{paymentDateTime},#{updateDateTime})")
	void createPayment(Payment payment);

	@Update("UPDATE airticketbooking.payment SET payment_amount = #{paymentAmount}, payment_date_time = #{paymentDateTime}," +
			" update_date_time = #{updateDateTime} WHERE payment_id = #{paymentId}")
	void modifyPayment(Payment payment);

	@Select("SELECT * FROM airticketbooking.payment WHERE payment_id = #{id}")
	Payment getPaymentById(Integer id);

	@Select("SELECT * FROM airticketbooking.payment WHERE order_id = #{orderId}")
	Payment getPaymentByOrderId(Integer orderId);
}
